package com.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 微信公众号开发--微信昵称中含有emoji字符串处理
 * https://blog.csdn.net/u012613902/article/details/78716972
* @Title:emoji特殊处理
* @author:zh
* @date:2018-7-11 10:45
 */
public class EmojiStringUtils {
	/**
	* @Title:判断是否存在特殊字符串
	* @param
	* @author:zh
	* @date:2018-7-11 10:45
	 */
    public static boolean hasEmoji(String content){
        Pattern pattern = Pattern.compile("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]");
        Matcher matcher = pattern.matcher(content);
        if(matcher .find()){
            return true;    
        }
            return false;
    }
    /**
    * @Title:替换字符串中的emoji字符
    * @param
    * @author:zh
    * @date:2018-7-11 10:45
     */
    public static String replaceEmoji(String str){
    	if(!hasEmoji(str)){
    		return str;
    	}else{
    		str=str.replaceAll("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]", " ");
    		return str;
    	}
    	
    }
}
